﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.XtraReports.UI;

public partial class Store_Keeper_SK_Rpt_GTN : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["current"] = "GTN Report";//current page

        if (Session["user"] != null)//check user
        {
            string user = Session["user"].ToString();
            if (user == "viewer")
            {
                Response.Redirect("index.aspx");
            }

        }
        else
        {
            Response.Redirect("index.aspx");
        }
        ReportViewer1.Report = CreateReport();
    }

    XtraReport CreateReport()
    {

        //RPT_GRN report = new RPT_GRN();
        //Rpt_GRN report = new Rpt_GRN();
        Rpt_GTN report = new Rpt_GTN();
        report.GTNno.Value= GetSelectedValue(1);
        if (report.GTNno.Value.ToString() == "1")
        {
        }
        else
        {
            report.CreateDocument();

        }
        return report;
    }

    int GetSelectedValue(int defaultValue)
    {
        if (DropDownList1.SelectedItem != null)
        {
            return Convert.ToInt32(DropDownList1.SelectedItem.Value);
        }
        else
        {
            return defaultValue;
        }
    }




    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

        ReportViewer1.Report = CreateReport();
    }
}